﻿using System;
using System.Collections.Generic;

namespace DISP.Core
{
    /// <summary>
    /// 
    /// </summary>
    public static class DependencyInjectionServiceProvider
    {
        private static IoCContainerFactory _ioCContainerProvider;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="containerTypeEnum"></param>
        /// <param name="services"></param>
        public static void Initialize(IoCContainerTypeEnum containerTypeEnum, IEnumerable<DependencyInjectionService> services)
        {
            if (_ioCContainerProvider == null)
            {
                _ioCContainerProvider = new IoCContainerFactory(containerTypeEnum, services);
            }
        }

        public static void Bind(DependencyInjectionService services)
        {
            if (_ioCContainerProvider != null)
            {
                _ioCContainerProvider.BindService(services);
            }
            else
            {
                throw new NullReferenceException("Call Initialize first");
            }
        }

        public static Object Get(Type service)
        {
            if (_ioCContainerProvider != null)
            {
                return _ioCContainerProvider.GetService(service);
            }
            throw new NullReferenceException("Call Initialize first");
        }

        public static void Dispose()
        {

        }
    }
}
